import Vue from 'vue'
import Vuex from 'vuex'
import http from '../utils/http'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user:{},
    activeTab: 'parent-registration'
  },
  getters: {
  },
  mutations: {
    setUser(state,user){
      state.user=user
    },
    changeActiveTab(state, str) {
      state.activeTab = str
    }
  },
  actions: {
    getUser(context,userid){
      http.get(`/parents/${userid}`).then(res=>{
        context.commit('setUser',JSON.parse(JSON.stringify(res.data)))
      }).catch(error=>{
        console.error('in \'store\\index.js\':GET USERINFO ERROR')
      })
    }
  },
  modules: {
  }
})
